package com.yunban.project.template.controller;

import com.yunban.project.template.model.dto.TypeReq;
import com.yunban.project.template.model.dto.TypeSearchReq;
import com.yunban.project.template.model.vo.TypeResp;
import com.yunban.project.template.service.TypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.module.support.operatelog.annotation.OperateLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author: lijiajun
 * @date: 2024-11-06
 * @version: 1.0
 */
@OperateLog
@RestController
@Tag(name = "模板类型模块")
@RequestMapping("/type-api")
public class TypeController {

    @Resource
    private TypeService typeService;

    @NoNeedLogin
    @GetMapping("/list")
    @Operation(summary = "获取模板类型列表")
    PageResult<TypeResp> getTypeList(TypeSearchReq req) {
        return typeService.getTypeList(req);
    }

    @PostMapping
    @Operation(summary = "添加模板类型信息")
    Long saveType(@RequestBody @Validated TypeReq req) {
        return typeService.saveType(req);
    }

    @PutMapping("/{id}")
    @Operation(summary = "修改模板类型信息")
    Boolean editType(@PathVariable long id, @RequestBody @Validated TypeReq req) {
        return this.typeService.editType(id, req);
    }

    @DeleteMapping("/{id}")
    @Operation(summary = "删除模板类型信息")
    Boolean delType(@PathVariable long id) {
        return this.typeService.delType(id);
    }
}
